<template>
  <div class="app-container" v-loading="loadings">
    <!-- 补贴单信息 -->
    <h5 class="titleInfo">
      补贴单信息
    </h5>
    <el-form ref="list" :inline="true" label-width="130px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="补贴单号">
            <span v-if="list.data" class="spanToInput">{{
              list.data.applySn | filterNull
            }}</span>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
                    <el-form-item label="流水单号">
                        <span class="spanToInput">{{list.orderSn | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="预约单号">
                        <span class="spanToInput">{{list.projectOrderSn | filterNull}}</span>
                    </el-form-item>
                </el-col> -->
                <el-col :span="12">
                    <el-form-item label="预约医院">
                        <span v-if="list.data" class="spanToInput">{{list.data.hospitalName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="预约项目">
                        <span v-if="list.data" class="spanToInput">{{list.data.projectName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="创建日期">
                        <span v-if="list.data" class="spanToInput">{{list.data.createdAtStr | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="流水时间">
                        <span v-if="list.data" class="spanToInput">{{list.data.projectOrder.createdAtStr | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="单数">
                        <span class="spanToInput">{{list.count | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="是否全额">
                        <span v-if="list.data" class="spanToInput">
                            {{list.isFull | isFull}}
                        </span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="已使用全额金额">
                        <span class="spanToInput">{{list.discountAmount | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="活动名称">
                        <span v-if="list.data" class="spanToInput">{{list.data.projectOrder.salesType | salesTypeFilter}}</span>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <!-- 人员信息 -->
        <div class="divBar"></div>
        <h5 class="titleInfo">
            人员信息
        </h5>
        <el-form ref="list" :inline="true" :model="list" label-width="130px">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="客户姓名">
                        <span v-if="list.data" class="spanToInput">{{list.data.user==null?null:list.data.user.realname | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="客户手机号">
                        <span v-if="list.data" class="spanToInput">{{list.data.user==null?null:list.data.user.username | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="推荐人姓名">
                        <span v-if="list.data" class="spanToInput">{{list.data.server==null?null:list.data.server.realname | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="推荐人手机号">
                        <span v-if="list.data" class="spanToInput">{{list.data.server==null?null:list.data.server.username | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="管家姓名">
                        <span v-if="list.data" class="spanToInput">{{list.data.butler==null?null:list.data.butler.realname | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="管家手机号">
                        <span v-if="list.data" class="spanToInput">{{list.data.butler==null?null:list.data.butler.username | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="用户角色">
                        <span v-if="list.data" class="spanToInput">{{list.data.role==null?null:list.data.role.roleName | filterNull}}</span>
                    </el-form-item>
                </el-col>
                 <el-col :span="12">
                    <el-form-item label="加盟时间">
                        <span v-if="list.data" class="spanToInput">{{list.data.user==null?null:list.data.user.joinTime | filterNull}}</span>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="考核">
                        <span v-if="list.data" class="spanToInput">{{list.isCheck==1?'需要考核':'无需考核'}}</span>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <!-- 补贴信息 -->
        <!-- list.disableAllowanceInfoDisplay!=1 -->
    <div v-if="list.disableAllowanceInfoDisplay!=1">    
        <div class="divBar"></div>
        <h5 class="titleInfo">
            补贴信息
            <!-- <el-button style="margin-left:30px" @click="dialogResults=true" size="mini" type="primary">每月业绩</el-button> -->
        </h5>
        <!-- 每月业绩弹窗 -->
        <!-- <el-dialog title="每月业绩" :visible.sync="dialogResults" width="468px">
            <template>
                <el-table
                    :data="tableData"
                    border
                    style="width:432px"
                    >
                    <el-table-column
                    prop="ym"
                    label="日期"
                    width="216">
                    </el-table-column>
                    <el-table-column
                    prop="achive"
                    label="姓名">
                    </el-table-column>
                </el-table>
            </template>
        </el-dialog> -->
      <el-form ref="list" :inline="true" :model="list" label-width="130px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="扣除杂费">
              <span class="spanToInput">{{ list.allPrice }}</span>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
                    <el-form-item label="奖励金额">
                        <span  v-if="list.data" class="spanToInput">{{list.data.projectOrder.rewardPrice | filterNull}}</span>
                    </el-form-item>
                </el-col> -->
          <!-- <el-col :span="12">
                    <el-form-item v-if="list.data" label="现金补贴">
                        <span class="spanToInput">{{list.data.projectOrder.cashAllowance | filterNull}}</span>
                    </el-form-item>
                </el-col> -->
          <!-- <el-col :span="12">
                    <el-form-item v-if="list.data" label="积分补贴">
                        <span class="spanToInput">{{list.data.projectOrder.integralAllowance | filterNull}}</span>
                    </el-form-item>
                </el-col> -->
          <el-col :span="12">
            <el-form-item label="杂费金额">
              <span class="spanToInput">{{
                list.otherAllowance | filterNull
              }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="消费金额">
              <span v-if="list.data" class="spanToInput">
                {{ list.totalMoney }}
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="补贴金额">
              <span class="spanToInput">{{ list.money | filterNull }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="金币补贴">
              <span class="spanToInput" v-if="list.protocol"
                >{{ list.protocol.smallCoin || 0 }}
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="期数/次">
              <span class="spanToInput">{{ list.coinNum | filterNull }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="银币补贴">
              <span class="spanToInput" v-if="list.protocol">
                {{ list.protocol.smallCredit | filterNull }}</span
              >
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="期数/次">
              <span class="spanToInput">{{ list.creditNum | filterNull }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="共补贴期数">
              <span class="spanToInput">{{ list.applyNum | filterNull }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12"> 
            <el-form-item label="流水单备注">
              <span v-if="list.data" class="spanToInput">
                {{ list.data.projectOrder.userRemark }}
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="补贴单备注">
              <span class="spanToInput">
                {{ list.remark }}
              </span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item v-if="list.data" label="首次补贴">
              <span class="spanToInput">{{ list.allowanceTimeStr }}</span>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 图片信息 -->
    <div class="divBar"></div>
    <h5 class="titleInfo">
      图片信息
    </h5>
    <el-form ref="list" :inline="true" :model="list" label-width="130px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="消费图片" v-if="list.data">
            <div v-if="list.data.img4List.length > 0" class="imgList_pic">
              <img
                v-for="(item, index) in list.data.img4List"
                :key="index"
                :src="item ? imgUrlPrefix + item : ''"
                alt=""
              />
            </div>
            <div v-else>
              <span class="spanToInput">暂无</span>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="前后图片" v-if="list.data">
            <div v-if="list.data.img5List.length > 0" class="imgList_pic">
              <img
                v-for="(item, index) in list.data.img5List"
                :key="index"
                :src="item ? imgUrlPrefix + item : ''"
                alt=""
              />
            </div>
            <div v-else>
              <span class="spanToInput">暂无</span>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { detailProject, detailRefundProject } from "@/api/subsidyManage";
import commonFn from "@/utils/common.js"
export default {
  name: "subsidyManageInfo",
  data() {
    return {
      loadings: true,
      imgUrlPrefix: localStorage.getItem("imgUrlPrefix"),
      val: "1",
      userId: "",
      dialogResults: false,
      list: {},
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎"
        }
      ]
    };
  },
  filters: {
    salesTypeFilter(e){
      for(let i in commonFn.list){
        if(e==i){
          return commonFn.list[i]
        }
      }
      // switch (String(e)) {
      //   case "0":
      //     return "无促销活动";
      //   case "1":
      //     return "2020服务商加盟全额补";
      //   case "2":
      //     return "超级卖手90%补贴";
      //   case "2020":
      //     return "2020定金全额补";
      //   default:
      //     return "暂无";
      // }  
    },
    filterNull(e) {
      return e;
      // if(!e){
      //     return "暂无"
      // }else{
      //     return e
      // }
    },
    cardNull(e) {
      return window.helper.cardType(e);
    },
    isFull(e) {
      if (e == 0) {
        return "否";
      } else {
        return "是";
      }
    },
    userFocus(e) {
      return window.helper.userFocus(e);
    }
  },
  mounted() {
    this.userId = String(this.$route.query.id);
    this.ids = String(this.$route.query.ids);
    this.getList();
  },
  methods: {
    getList() {
      this.loadings = true;
      let datas = { id: this.userId };
      if (this.ids == "detailProject") {
        detailProject(datas)
          .then()
          .then(res => {
            console.log(res);
            if (!res.data.code) {
              this.list = res.data.data;
              this.tableData = res.data.data.data.achievements;
            } else {
              this.$message.error(res.data.msg);
            }
            this.loadings = false;
          })
          .catch(error => {
            this.$message.error(error);
            this.loadings = false;
          });
      } else {
        detailRefundProject(datas)
          .then()
          .then(res => {
            console.log(res);
            if (!res.data.code) {
              this.list = res.data.data;
              this.tableData = res.data.data.data.achievements;
            } else {
              this.$message.error(res.data.msg);
            }
            this.loadings = false;
          })
          .catch(error => {
            this.$message.error(error);
            this.loadings = false;
          });
      }
    }
  }
};
</script>

<style scoped>
.app-container {
  padding: 0px !important;
}
.form {
  margin-left: 268px;
}
.imgList_pic {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}
.imgList_pic img {
  width: 200px;
  height: auto;
  margin: 10px;
}
</style>
